Create-A-Card

The Create-A-Card application lets you create a custom birthday card. When you enter the name and age of a recipient and click submit, the application returns a page with a birthday greeting. The application maintains a global variable namesArray that contains the names of all card recipients. When a user clicks the 'Show all recipients' button, the application returns a page listing all of the recipients across all sessions.


Notable Create-A-Card Components

Application
The Application script declares a global variable, namesArray, that holds the names of all birthday card recipients. This array is maintained for the application itself, meaning that if multiple users access the application, each of their recipients will be added to the array. Clicking the 'Show all recipients' button displays the entire contents of the array, including the names that other users have added.
Main
The Main script takes the information a user enters into the recipient name, age, and message fields, and generates a custom birthday card from it. It also adds the current recipient to the global variable namesArray.

Interesting Issues From Create-A-Card

Using a WORepetition

The Create-A-Card application uses a WORepetition, which is a dynamic element that displays itself as a list in an HTML page. A WORepetition has two attributes: a list, which is an NSArray object that contains a collection of items, and an item, which is an NSDictionary that represents an item in the list. An NSDictionary is a collection of key-value pairs. Each NSDictionary object in the namesArray includes the key "aName" whose corresponding value is the name of a recipient.

This WORepetition is declared in the declarations file Recipients.wod. The second declaration sets the value of anItem to be aName, which corresponds to the name of a recipient:

    NAMEGROUP:WORepetition {
	list = WOApp.namesArray;
	item = anItem;
    };

    NAMEGROUP.A_NAME:WOString {
	value = anItem.aName;
    };

When a user clicks the 'Show all recipients' button to navigate to the Recipients page, the namesArray is iterated, and the name of each recipient is displayed-- or, to put it differently, the value associated with the key aName in each anItem NSDictionary is displayed.